cmake_minimum_required(VERSION 3.10.2)

###########################################################
#### Project configuration                             ####
###########################################################

project(MMMLegacyMotionViewer)

###########################################################
#### Source configuration                              ####
###########################################################

set(SOURCE_FILES
    MMMLegacyMotionViewerMain.cpp
    MMMLegacyMotionViewerWindow.cpp
    #MMMLegacyMotionViewer.cpp
)

set(HEADER_FILES
    MMMLegacyMotionViewerWindow.h
    MMMLegacyMotionViewerConfiguration.h
    #MMMLegacyMotionViewer.h
)

set(MOC_FILES
    MMMLegacyMotionViewerWindow.h
)

set(UI_FILES
    MMMLegacyMotionViewer.ui
)

###########################################################
#### CMake package configuration                       ####
###########################################################

find_package(MMMCore REQUIRED)
set(EXTERNAL_LIBRARY_DIRS ${EXTERNAL_LIBRARY_DIRS} MMMCore)

find_package(Simox REQUIRED)
set(EXTERNAL_LIBRARY_DIRS ${EXTERNAL_LIBRARY_DIRS} VirtualRobot)

set(EXTERNAL_LIBRARY_DIRS ${EXTERNAL_LIBRARY_DIRS} MMMSimoxTools)

###########################################################
#### Project build configuration                       ####
###########################################################

# create the executable
SimoxQtApplication(${PROJECT_NAME} "${SOURCE_FILES}" "${HEADER_FILES}" "${MOC_FILES}" "${UI_FILES}")
target_link_libraries(${PROJECT_NAME} PRIVATE ${EXTERNAL_LIBRARY_DIRS} dl)

#GET_FILENAME_COMPONENT (CurrentPath ${CMAKE_CURRENT_LIST_FILE} PATH)

set(MMMLegacyMotionViewer_BASE_DIR ${PROJECT_SOURCE_DIR} CACHE INTERNAL "" )
add_definitions(-DMMMLegacyMotionViewer_BASE_DIR="${MMMLegacyMotionViewer_BASE_DIR}" -D_SCL_SECURE_NO_WARNINGS)

install(
    TARGETS ${PROJECT_NAME}
    EXPORT "${CMAKE_PROJECT_NAME}Targets"
    #LIBRARY DESTINATION lib
    #ARCHIVE DESTINATION lib
    RUNTIME DESTINATION bin
    #INCLUDES DESTINATION include
    COMPONENT bin
)

#add_subdirectory(tests) # TODO: fix tests
add_definitions(-DMMMTools_LIB_DIR="${MMMTools_LIB_DIR}")

###########################################################
#### Compiler configuration                            ####
###########################################################

include_directories(${EXTERNAL_INCLUDE_DIRS})
link_directories(${EXTERNAL_LIBRARY_DIRS})
add_definitions(${EXTERNAL_LIBRARY_FLAGS})